@extends('layouts.master3')
@section('content')
@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}
    </div>
@endif
@section('css')
<link href="http://www.qlcoder.com/css/login.css" rel="stylesheet">
@stop

@if($errors->any())
    <div class="alert alert-danger">
<h4>{{$errors->first()}}</h4>
    </div>
@endif
<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <p>
                <font color="#FF0000">
                </font>
            </p>
            <div class="panel panel-login">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-md-12">
                            <a href="#" class="active" id="login-form-link">找回密码</a>
                        </div>

                    </div>
                    <hr>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-12">
                            
                            {!! csrf_field() !!}
                                <div class="form-group" style="position:relative">
                                    <input type="email" name="email" id="email" tabindex="1" class="form-control" placeholder="邮箱" value="">
                                    <span class="unknown none" style="position:absolute;color:red;top: 12px;right: 12px;font-size: 16px;">该邮箱暂未注册千里码</span>
                                </div>
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-sm-6 col-sm-offset-3">
                                            <input type="submit" name="login-submit" id="verify" tabindex="2" data-time="60" class="form-control btn btn-login" value="发送验证">
                                        </div>
                                    </div>
                                </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
@section('js')
<script>
    $(function(){
        var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        $("#email").bind("input propertychange",function(){
            $(".unknown").addClass("none");
        })
        $("#verify").click(function(){
            var _email=$("#email").val();
            var _token=$("input[name='_token']").val();
			var _this=this;
            if(filter.test($("#email").val()))
            {
                $.post("http://www.qlcoder.com/password/email",{email:_email,_token:_token},function(data){
                    //console.log(data.res);
                    if(data.res)
                    {
                        $("#email").attr("readonly","readonly");
                        $(_this).attr({"disabled":"disabled"}).css({"border":"none","color":"black"}).val("60S后重新发送");
                        setTimeout(function(){wait(60)},0);
                    }
                    else{
                        $(".unknown").removeClass("none").html("该邮箱暂未注册千里码");
                    }
                })
            }
            else{
                $(".unknown").removeClass("none").html("邮箱格式不正确");
            }
            
        })
    });
    function wait(d){
        var t=d;
        if(t>=1){
            t--;
            $("#verify").attr("data-time",t).val(t+"S后重新发送");
            setTimeout(function(){wait(t)},1000);
        }
        else{
            $("#email").removeAttr("readonly");
            $("#verify").val("重新发送验证").removeAttr("disabled style").attr("data-time",60);
            return !1;
        }
    }
</script>
<script>
    if(document.getElementsByClassName("container")[0]!=null)
        document.getElementsByClassName("container")[0].style.minHeight=window.innerHeight-140+"px";
</script>
@stop
